/* 封装 访问mysql 数据库 */
var mysql = require('mysql');

var mydb = {
    host     : 'localhost',
    user     : 'root',
    password : '12345678',
    database : 'study'
};

function runsql(sql,callback,val = null){
    //连接
    var conn = mysql.createConnection(mydb);
    conn.connect(); 
    if(val == null){  // 
        conn.query(sql,callback)
    }else{
        conn.query(sql,val,callback)
    }
    conn.end();
}

//导出
module.exports = runsql 